home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Documentation / Tech Notes & Articles / Recipes / Imaging & Layout / RequestingEmbeddedFrame recipe < prev    next >
Encoding:
Text File  |  1995-07-10  |  2.8 KB  |  87 lines  |  [TEXT/ttxt]

  1. OpenDoc™ Recipes
  2.  
  3.  
  4. RequestEmbeddedFrame recipe
  5. By The OpenDoc Design Team
  6. April 1994
  7.  
  8.  
  9. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  10. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  11. Mac and OpenDoc are trademarks of Apple Computer, Inc.
  12.  
  13.  
  14. Introduction
  15.  
  16. One of the methods which part editors which support embedding may need to override is RequestEmbeddedFrame.
  17.  
  18. As part of this recipe the part editor will probably want to put the general functionality of creating a frame for embedding into another method, say CreateEmbeddedFrame, which would be called from RequestEmbeddedFrame.  Note that RequestEmbeddedFrame should only be called by an embedded part on its containing part in order to get a sibling frame.  That is why this call takes a baseFrame parameter.  The baseFrame must already be embedded inside the part receiving the RequestEmbeddedFrame message.  The CreateEmbeddedFrame method is used in the Clipboard and Insert… recipes.
  19.  
  20. Caveats
  21.  
  22. • This code assumes the containing part is not picky about the requested frameShape and externalTransform, and always returns the requested embedded frame.
  23.  
  24. • It does not contain proper error checking
  25.  
  26. • It assumes all embedded frames are kept in a single list
  27.  
  28. Sample Code
  29.  
  30. #include "Frame.h"
  31. #include "Draft.h"
  32. #include "StorageU.h"
  33.  
  34. ...
  35.  
  36. ODFrame* MyPartRequestEmbeddedFrame(MyPart* somSelf, Environment* ev,
  37.                         ODFrame* containingFrame,
  38.                         ODFrame* baseFrame,
  39.                         ODShape* frameShape,
  40.                         ODPart* embedPart,
  41.                         ODTypeToken viewType,
  42.                         ODTypeToken presentation,
  43.                         ODBoolean isOverlaid)
  44. {
  45.     ODFrame* newFrame = somSelf->CreateEmbeddedFrame(ev,
  46.                             containingFrame,
  47.                             frameShape,
  48.                             externalTransform,
  49.                             embedPart,
  50.                             viewType,
  51.                             presentation,
  52.                             baseFrame->GetFrameGroup(),
  53.                             isOverlaid);
  54. }
  55.  
  56.  
  57. // private implementation method:
  58. ODFrame* MyPartCreateEmbeddedFrame(MyPart* somSelf, Environment* ev,
  59.                         ODFrame*                                            containingFrame,
  60.                         ODShape*                                            frameShape,
  61.                         ODTransform*                            externalTransform,
  62.                         ODPart*                                             part,
  63.                         ODTypeToken                                viewType,
  64.                         ODTypeToken                                presentation,
  65.                         ODID                                                            frameGroupID,
  66.                         ODBoolean                                     isOverlaid)
  67. {
  68.     ODFrame* newFrame
  69.         = somSelf->GetStorageUnit(ev)->GetDraft(ev)->CreateFrame(ev,
  70.                             kODNULL,                                                    // default type is persistent
  71.                             containingFrame,
  72.                             frameShape,
  73.                             kODNULL,                                                    // no bias canvas
  74.                             part,
  75.                             viewType,
  76.                             presentation,
  77.                             kODFalse,            // not a subframe
  78.                             isOverlaid)
  79.     newFrame->SetFrameGroup(ev, frameGroupID);
  80.     newFrame->SetSequenceNumber(ev, somSelf->NextInGroup(ev, frameGroupID);
  81.     // Add frame to list of embedded frames, and keep track of
  82.     // the externalTransform for that frame tç
  83.     fMyEmbeddedFrameList->Add(newFrame,externalTransform);
  84.  
  85.     return newFrame;
  86. }
  87.